USE [LoadTest]
GO
/****** Object:  StoredProcedure [dbo].[RPT_SelectLoadTestSummary]    Script Date: 05/28/2006 19:38:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO

CREATE PROCEDURE [dbo].[rpt_SelectLoadTestSummary] 
@LoadTestName nvarchar(255), 
@PastDays int
AS
BEGIN	  	  
		IF (@LoadTestName = 'All Tests') 
			BEGIN	 
				SELECT  LoadTestName,LoadTestRunId, Description, StartTime, EndTime, RunDuration, Outcome  
				FROM dbo.LoadTestRun 
				WHERE DateDiff(day, EndTime, GetDate()) <= @PastDays
				Order by LoadTestRunId desc
			END
		ELSE
			BEGIN
				SELECT  LoadTestName,LoadTestRunId, Description, StartTime, EndTime, RunDuration, Outcome  
				FROM dbo.LoadTestRun 
				WHERE LoadTestName = @LoadTestName 
				AND  DateDiff(day, EndTime, GetDate()) <= @PastDays
				Order by LoadTestRunId desc
			END
		END	
